import request from '@/router/axios'

export function fetchList(query) {
  return request({
    url: '/eims/familyGroup/page',
    method: 'get',
    params: query
  })
}

export function addObj(obj) {
  return request({
    url: '/eims/familyGroup',
    method: 'post',
    data: obj
  })
}

export function getFamilyById(id) {
  return request({
    url: '/eims/familyGroup/' + id,
    method: 'get'
  })
}

export function delObj(id) {
  return request({
    url: '/eims/familyGroup/' + id,
    method: 'delete'
  })
}

export function putObj(obj) {
  return request({
    url: '/eims/familyGroup',
    method: 'put',
    data: obj
  })
}

export function getInfoByCustomerId(customerId,currentDeptId) {
  return request({
    url: '/eims/familyGroup/getInfo/' + customerId +'/' + currentDeptId,
    method: 'get'
  })
}

export function editInfoLink(obj) {
  return request({
    url: '/eims/familyLink/editLink',
    method: 'put',
    data: obj
  })
}

//通过会员Id查询家庭组积分总计（若不存在家庭组，则返回该会员的积分）
export function getSumIntegralByCustomerId(customerId) {
  return request({
    url: '/eims/familyGroup/getSumIntegral/' + customerId,
    method: 'get'
  })
}

//通过会员Id查询家庭组积分总计（若不存在家庭组，则返回0）
export function getSumIntegralByCustomerId2(customerId,lessDeptId) {
  return request({
    url: '/eims/familyGroup/getSumIntegral2/' + customerId + '/' +lessDeptId,
    method: 'get'
  })
}